package cn.iotab.iotkit.transport.api.access.model.custom.firmware;

import cn.iotab.iotkit.transport.api.access.model.message.CommonDeviceMessage;
import cn.iotab.iotkit.transport.api.access.model.message.OriginMessage;
import com.alibaba.fastjson.JSONObject;
import lombok.Getter;
import lombok.Setter;

import java.util.Map;

/**
 * 设备上报固件信息
 *  设备 -> 平台
 */
@Getter
@Setter
public class ReportFirmwareMessage extends CommonDeviceMessage {

    //版本号
    private String version;

    //其他属性
    private Map<String, Object> properties;

    @Override
    public void fromOriginMessage(String productKey, String deviceId, OriginMessage message) {
        super.fromOriginMessage(productKey, deviceId, message);
        JSONObject jsonObject = getJsonParam();
        this.version = jsonObject.getString("version");
        this.properties = jsonObject.getJSONObject("properties");
    }

    @Override
    public OriginMessage toOriginMessage() {
        throw new UnsupportedOperationException("unsupported operation for not support platform report FirmwareMessage to device");
    }
}
